<?php

namespace App\Models\customer;

use App\Models\AdminModel;
use App\Models\cainiao\AsnModel;
use App\Models\CustomerModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model as BaseModel;


class WarnModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_sop_node_warn';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    const STATUS = [1 => '待处理', 2 => '已补录轨迹', 3 => '超时完成', 4 => '已转问题件'];

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];



    //创建人
    public function create_admin(): BelongsTo {
        return $this->belongsTo(AdminModel::class, 'created_admin_id');
    }

    //报警节点
    public function warn_node(): BelongsTo {
        return $this->belongsTo(NodeModel::class, 'node_id');
    }

    //补录节点
    public function repair_node(): BelongsTo {
        return $this->belongsTo(NodeModel::class, 'node_id');
    }

    //小包
    public function asn(): BelongsTo {
        return $this->belongsTo(AsnModel::class, 'asn_id');
    }

    //客户
    public function customer(): BelongsTo {
        return $this->belongsTo(CustomerModel::class, 'customer_id');
    }
}
